package com.n.util;

public class Test {
	public static void main(String[] args) {
		String sql = "select r.c_customerId,c.c_name as c_customerName,"
				+"sum( case  when  month(c_date )= 1  and r.c_type=1 then c_money else 0 end )  as 'q_1',"
				+"sum( case  when month(c_date )= 2  and r.c_type=1 then c_money else 0 end )  as 'q_2',"
				+"sum( case  when month(c_date )= 3  and r.c_type=1 then c_money else 0 end )  as 'q_3',"
				+"sum( case  when month(c_date )=4  and r.c_type=1 then c_money else 0 end )  as 'q_4',"
				+"sum( case  when month(c_date )= 5 and r.c_type=1 then c_money else 0 end )  as 'q_5',"
				+"sum( case  when month(c_date )= 6 and r.c_type=1 then c_money else 0 end )  as 'q_6',"
				+"sum( case  when month(c_date )= 7 and r.c_type=1 then c_money else 0 end )  as 'q_7',"
				+"sum( case  when month(c_date )= 8 and r.c_type=1 then c_money else 0 end )  as 'q_8',"
				+"sum( case  when month(c_date )= 9 and r.c_type=1 then c_money else 0 end )  as 'q_9',"
				+"sum( case  when month(c_date )= 10 and r.c_type=1 then c_money else 0 end )  as 'q_10',"
				+"sum( case  when month(c_date )= 11 and r.c_type=1 then c_money else 0 end )  as 'q_11',"
				+"sum( case  when month(c_date )= 12 and r.c_type=1 then c_money else 0 end )  as 'q_12',"
				+"sum( case  when  month(c_date )= 1  and r.c_type=2 then c_money else 0 end )  as 'h_1',"
				+"sum( case  when month(c_date )= 2  and r.c_type=2 then c_money else 0 end )  as 'h_2',"
				+"sum( case  when month(c_date )= 3  and r.c_type=2 then c_money else 0 end )  as 'h_3',"
				+"sum( case  when month(c_date )=4  and r.c_type=2 then c_money else 0 end )  as 'h_4',"
				+"sum( case  when month(c_date )= 5 and r.c_type=2 then c_money else 0 end )  as 'h_5',"
				+"sum( case  when month(c_date )= 6 and r.c_type=2 then c_money else 0 end )  as 'h_6',"
				+"sum( case  when month(c_date )= 7 and r.c_type=2 then c_money else 0 end )  as 'h_7',"
				+"sum( case  when month(c_date )= 8 and r.c_type=2 then c_money else 0 end )  as 'h_8',"
				+"sum( case  when month(c_date )= 9 and r.c_type=2 then c_money else 0 end )  as 'h_9',"
				+"sum( case  when month(c_date )= 10 and r.c_type=2 then c_money else 0 end )  as 'h_10',"
				+"sum( case  when month(c_date )= 11 and r.c_type=2 then c_money else 0 end )  as 'h_11',"
				+"sum( case  when month(c_date )= 12 and r.c_type=2 then c_money else 0 end )  as 'h_12'"
				+" from customer c,customerbillrecord r where c.c_id=r.c_customerId "
				+" and YEAR(c_date)="+2014
				+" group by r.c_customerId,c_customerName";
		
		System.out.println(sql);
	}
}
